package View;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.net.URL;

import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JPanel;


public class Clio{
	
	private static JFrame frame = new JFrame("Clio Make-Up");
	
	private static Home home = new Home();
	
	private static Menu menu = new Menu();
	
	public Clio(){}
	
	public static void CreateAndShowGUI(){
		
		frame.setIconImage(Clio.createImageIcon("images/trucco.png").getImage());
		
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		
		frame.setMinimumSize(new Dimension(966,724));
		
		frame.setLocationRelativeTo(null);

		frame.getContentPane().add(menu,BorderLayout.NORTH); 
		
		frame.getContentPane().add(home,BorderLayout.CENTER);
		
		home.setName("home");
		
		frame.pack();
		
		frame.setVisible(true);
	}
	
	public static void AggiornaGUI(JPanel panel, String nome){
		
		frame.getContentPane().getComponents()[1].setVisible(false);
		
		frame.getContentPane().remove(frame.getContentPane().getComponents()[1]);
		
		frame.getContentPane().add(panel,BorderLayout.CENTER);
		
		frame.getContentPane().getComponents()[1].setName(nome);
	}
	
	public static void clio (){
		
		javax.swing.SwingUtilities.invokeLater(new Runnable(){
			@Override
			public void run() {
				
				CreateAndShowGUI();
			}
		});
		
	}

	protected static ImageIcon createImageIcon(String path) {
        java.net.URL imgURL = Clio.class.getResource(path);
        if (imgURL != null) {
            return new ImageIcon(imgURL);
        } else {
            System.err.println("File non trovato: " + path);
            return null;
        }
    }
	
	public static JFrame getFrame(){
		
		return Clio.frame;
	}
	
	protected static URL createURL(String path) {
        URL imgURL = Clio.class.getResource(path);
        if (imgURL != null) {
            return imgURL;
        } else {
            System.err.println("File non trovato: " + path);
            return null;
        }
    }
	
	

}
